import React from 'react'
import styles from './style.less'

export default class TodoItem extends React.Component {

	constructor(props) {
		super(props)
		this.handleDelete = this.handleDelete.bind(this)
	}

	// 子组件想要跟父组件通信，子组件要调用父组件穿递过来的方法

	handleDelete(){
		this.props.delete(this.props.index)
	}

	render() {
		return (
			<li className={styles.listTtem}>
				<p>{this.props.item}</p><span onClick={this.handleDelete}>删除</span>
			</li>
		)
	}
}